package com.credithc.signature.common.constant;

import com.google.common.collect.Maps;

import java.util.Map;

/**
 * 描述：响应枚举类<br/>
 * 作者：sunyang
 * 创建：2019/5/28 14:55
 * 版本：v1.0.0<br/>
 */
public enum ResponseEnum {

    SUCCESS(0, "投递请求成功"),
    FAIL(-1, "投递请求失败"),
    ILLEGAL_CHANNEL(-2, "非法渠道"),
    ILLEGAL_TEMPLATE(-3, "非法模板"),
    ILLEGAL_OFFICIAL_SEAL(-4, "非法公章"),
    ILLEGAL_EXPIRE(-5, "过期请求"),
    ILLEGAL_SIGNATURE(-6, "非法签名"),
    ILLEGAL_TOKEN(-7, "非法Token"),
    ILLEGAL_REQUESTNO(-8, "根据RequestNo未查询到记录"),

    //签章状态码
    GET_PICTURE_FAILED(-9, "获取印章图片失败"),
    GET_CONTRACT_FAILED(-10, "PDF文件下载失败"),
    INVALID_CONTRACT(-11, "PDF文件不可用，请检查文件系统类型!"),
    ILLEGAL_PARAMS(-12, "非法参数"),
    ILLEGAL_PDFPATH(-13, "文件路径不能为空!"),
    UNNECESSARY_REVOKE(-14, "数据库版本为1,不需要回退"),
    VERIFY_SUCCESS(200, "参数校验成功"),
    SIGN_SUCCESS(201, "合同签章成功"),
    REVOKE_SUCCESS(202, "合同版本回退成功"),
    REVOKE_FAILED(203, "合同版本回退失败"),
    SIGN_FAILED(100, "合同签章失败"),

    //数据统计
    COUNT_SUCCESS(0, "成功");

    private int code;

    private String message;

    private static volatile Map<Integer, String> map = initMap();

    ResponseEnum(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public static Map<Integer, String> ofMap(){
        return map;
    }

    public int getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    private static Map<Integer, String> initMap() {
        ResponseEnum[] values = ResponseEnum.values();
        Map<Integer, String> map = Maps.newHashMapWithExpectedSize(values.length);
        for (ResponseEnum responseEnum : values) {
            map.put(responseEnum.getCode(), responseEnum.getMessage());
        }
        return map;
    }

}
